Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add aws_codestarconnections_connection resource #15990

Conversation

shuheiktgw
Copy link
Collaborator

@shuheiktgw shuheiktgw commented Nov 2, 2020

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Relates #15453, #15960
Closes #12637
Closes #11389

Release note for CHANGELOG:

* **New Resource:** `aws_codestarconnections_connection`

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccAWSCodeStarConnectionsConnection_*'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSCodeStarConnectionsConnection_* -timeout 120m
=== RUN   TestAccAWSCodeStarConnectionsConnection_Basic
=== PAUSE TestAccAWSCodeStarConnectionsConnection_Basic
=== RUN   TestAccAWSCodeStarConnectionsConnection_disappears
=== PAUSE TestAccAWSCodeStarConnectionsConnection_disappears
=== CONT  TestAccAWSCodeStarConnectionsConnection_disappears
=== CONT  TestAccAWSCodeStarConnectionsConnection_Basic
--- PASS: TestAccAWSCodeStarConnectionsConnection_disappears (36.78s)
--- PASS: TestAccAWSCodeStarConnectionsConnection_Basic (49.39s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	51.265s

This is the second part of a PR to add aws_codestarconnections_connection resource (the first part: #15960). This PR originally came from #12637. Thank you for your review!

@shuheiktgw shuheiktgw requested a review from a team as a code owner November 2, 2020 23:52
@ghost ghost added size/XL Managed by automation to categorize the size of a PR. provider Pertains to the provider itself, rather than any interaction with AWS. service/codestarconnections Issues and PRs that pertain to the codestarconnections service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Nov 2, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Nov 2, 2020
@shuheiktgw shuheiktgw force-pushed the add_codestar_connections_connection_resource branch 3 times, most recently from b585c07 to 6942de9 Compare November 3, 2020 00:01
Co-authored-by: Kévin Sénéchal <kevin.senechal@gmail.com>
@shuheiktgw shuheiktgw force-pushed the add_codestar_connections_connection_resource branch from 6942de9 to 222c479 Compare November 3, 2020 00:07
@shuheiktgw
Copy link
Collaborator Author

@bflad I've created the second part of the PR to support aws_codestarconnections_connection resource so would you review the PR?

Copy link
Contributor

@gdavison gdavison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, @shuheiktgw, it's looking good. I have a few suggestions for additions to the resource

aws/resource_aws_codestarconnections_connection.go Outdated Show resolved Hide resolved
Comment on lines 23 to 31
"arn": {
Type: schema.TypeString,
Computed: true,
},

"connection_arn": {
Type: schema.TypeString,
Computed: true,
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally, we prefer to follow the API, but in the case of "standard" outputs such as arn, it's ok to just have the arn and remove connection_arn

Computed: true,
},

"connection_name": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be renamed to name. It doesn't match the API, but it's a common pattern for resources to use the name parameter, and the resource type aws_codestarconnections_connection already mentions "connection" twice 🙂

Optionally, we can also use the name generation documented at https://github.com/hashicorp/terraform-provider-aws/blob/master/docs/contributing/contribution-checklists.md#adding-resource-name-generation-support


res, err := conn.CreateConnection(params)
if err != nil {
return fmt.Errorf("error creating codestar connection: %s", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We prefer error messages to use the Go 1.13 error wrapping verb %w.
For user-facing output, we should use the styling used by AWS

Suggested change
return fmt.Errorf("error creating codestar connection: %s", err)
return fmt.Errorf("error creating CodeStar connection: %w", err)

func resourceAwsCodeStarConnectionsConnectionRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).codestarconnectionsconn

rule, err := conn.GetConnection(&codestarconnections.GetConnectionInput{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rule should probably be renamed, since it doesn't return a rule. We often use resp.

Suggested change
rule, err := conn.GetConnection(&codestarconnections.GetConnectionInput{
resp, err := conn.GetConnection(&codestarconnections.GetConnectionInput{

@gdavison gdavison removed the needs-triage Waiting for first response or review from a maintainer. label Dec 12, 2020
@shuheiktgw
Copy link
Collaborator Author

@gdavison Thank you for your review! Let me fix them quickly 👍

Co-authored-by: Graham Davison <g.m.davison@computer.org>
@ghost ghost added the documentation Introduces or discusses updates to documentation. label Dec 14, 2020
@shuheiktgw
Copy link
Collaborator Author

@gdavison Thank you for your great reviews! I believe I fixed them up so would you review the PR again? 😄
I also reran the acc tests so please check the results below.

$ make testacc TESTARGS='-run=TestAccAWSCodeStarConnectionsConnection_*'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSCodeStarConnectionsConnection_* -timeout 120m
=== RUN   TestAccAWSCodeStarConnectionsConnection_Basic
=== PAUSE TestAccAWSCodeStarConnectionsConnection_Basic
=== RUN   TestAccAWSCodeStarConnectionsConnection_disappears
=== PAUSE TestAccAWSCodeStarConnectionsConnection_disappears
=== CONT  TestAccAWSCodeStarConnectionsConnection_disappears
=== CONT  TestAccAWSCodeStarConnectionsConnection_Basic
--- PASS: TestAccAWSCodeStarConnectionsConnection_disappears (36.78s)
--- PASS: TestAccAWSCodeStarConnectionsConnection_Basic (49.39s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	51.265s

Copy link
Contributor

@gdavison gdavison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates, @shuheiktgw! LGTM 🚀

--- PASS: TestAccAWSCodeStarConnectionsConnection_disappears (10.42s)
--- PASS: TestAccAWSCodeStarConnectionsConnection_Basic (14.08s)

@gdavison gdavison added this to the v3.22.0 milestone Dec 15, 2020
gdavison added a commit that referenced this pull request Dec 15, 2020
@gdavison gdavison merged commit 51e997d into hashicorp:master Dec 15, 2020
gdavison added a commit that referenced this pull request Dec 15, 2020
@shuheiktgw shuheiktgw deleted the add_codestar_connections_connection_resource branch December 16, 2020 10:45
@ghost
Copy link

ghost commented Dec 18, 2020

This has been released in version 3.22.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@ghost
Copy link

ghost commented Jan 15, 2021

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Jan 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. provider Pertains to the provider itself, rather than any interaction with AWS. service/codestarconnections Issues and PRs that pertain to the codestarconnections service. size/XL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Codepipeline Bitbucket Integration
2 participants